<template>
  <view>
    <wd-gap height="400px"/>
    <view class="tn-p">
      <wd-button open-type="getPhoneNumber" @getphonenumber="phoneLogin" block>
        手机号授权登录
      </wd-button>
    </view>
  </view>
</template>

<script setup lang="ts">
import {$user} from "@/store";

uni.hideHomeButton()

function phoneLogin(e: { code: string }) {
  if (!e.code)
    uni.showToast({title: "授权失败！", icon: "none"});
  $user.phoneLogin(e.code)
      .then(() => uni.reLaunch({url: '/pages/index/index'}))
}
</script>
